document.observe("dom:loaded", function(e) {    
 
    new Ajax.Request('/app/cars', {
        method:'GET',
        onSuccess: function(transport){
            var json = transport.responseText.evalJSON();
            var jdata = '';
            for (var j = 0; j < json.length; j++) {
                jdata += '<option value=' + json[j].cid + '>' + json[j].carname + "</option>";
            }
            $('list-cars').update(jdata);
        },
        onFailure: function(transport){
            $('list-cars').update('Can not get data from server!');
        }
    });
 
});
